package com.luych.toolbox.data.service.core.dm;

import com.luych.toolbox.common.enums.CaseType;
import com.luych.toolbox.common.enums.DataSourceType;
import com.luych.toolbox.data.service.core.CoreView;

public class DmView implements CoreView {

    private final String name;

    public DmView(CoreView coreView) {
        this.name = coreView.getName();
    }

    public DmView(String name) {
        this.name = name;
    }

    @Override
    public DataSourceType getDataSourceType() {
        return DataSourceType.DM;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public String getRemoveSql(CaseType caseType) {
        String tableName = caseType.getConvert().apply(this.getName());
        tableName = "\"" + tableName + "\"";
        return "DROP VIEW " + caseType.getConvert().apply(tableName) + ";";
    }
}
